<?php
class Header {
	public function render($title){
		$s = HtmlUtil::getSessionUser();
		
		$logged  = $s->isLogged();
		$admin= $s->isAdmin();
		$readonly = $s->isReadonly();
		
		$fullname = '';
		$login = '';
		
		if($logged){
			$fullname = $s->getUser()->getName();
			$login = $s->getUser()->getLogin();
		}
		 
		?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title><?php echo $title; ?></title>
	
	<script src="resource/jquery.js" type="text/javascript"></script>
	<script src="resource/jquery.lightbox-0.5.pack.js" type="text/javascript"></script>
	<script src="resource/script.js" type="text/javascript"></script>
	
	<script type="text/javascript">	
		jQuery(document).ready(selectFirst);
	</script>
	
	<link rel="stylesheet" type="text/css" href="resource/style.css" />
	<link rel="stylesheet" type="text/css" href="resource/jquery.lightbox-0.5.css" />
</head>

<body>
<div class="header">
  <h1>picture-album.info</h1>
  <div>
	<?php if (!$logged){ ?><a class="header" href="javascript: triggerform('login');">login</a><?php } ?>
	<?php if ( $logged){ ?><a class="header" href="javascript: triggerform('logout');">logout</a><?php } ?>
	<?php if ( $logged && !$readonly){ ?><a class="header" href="javascript: triggerform('profile');">profile</a><?php } ?>
	<?php if ( $logged && !$readonly){ ?><a class="header" href="javascript: triggerform('renalbums');">renumber albums</a><?php } ?>
	<?php if ( $logged && !$readonly){ ?><a class="header" href="javascript: triggerform('renpictures');">renumber pictures</a><?php } ?>
	<?php if ( $logged && !$readonly){ ?><a class="header" href="javascript: triggerform('orderalbums');">order albums</a><?php } ?>
	<?php if ( $logged && !$readonly){ ?><a class="header" href="javascript: triggerform('joblist');">jobs</a><?php } ?>
	<?php if ( $logged){ ?><a class="header" href="javascript: triggerform('albums');">albums</a><?php } ?>
	<?php if ( $logged && $admin && ! $readonly){ ?><a class="header" href="javascript: triggerform('users');">users</a><?php } ?>
	<?php if ( $logged && $admin && ! $readonly){ ?><a class="header" href="javascript: triggerform('movealbums');">move albums</a><?php } ?>
	<span style="padding-left: 100px">
	<?php if (!$logged) { ?> not logged in <?php } ?> 
	<?php if ( $logged) { echo "logged in as: $fullname ($login)";  } ?>
	<?php if($logged & !$readonly){ ?><span class="yes">edit mode</span><?php } ?>
	</span>
  </div>
</div>
<?php if(HtmlUtil::hasMessages()) {?>
	<div class="message"><?php echo HtmlUtil::getMessages(); ?></div>
<?php } ?>

<?php if(HtmlUtil::hasErrors()) {?>
	<div class="error"><?php  echo HtmlUtil::getErrors(); ?></div>
<?php } ?>

<div class="content">
		<?php 
	}
} 
?>
